package com.tbynet.jwp.framework.core;

import java.util.HashMap;
import java.util.Map;

// 基础异常
public class JwpException extends RuntimeException {
    private final String code;
    private final String message;
    private final Map<String, Object> context;

    public JwpException(String code, String message) {
        super(message);
        this.code = code;
        this.message = message;
        this.context = new HashMap<>();
    }

    public JwpException(String code, String message, Map<String, Object> context) {
        super(message);
        this.code = code;
        this.message = message;
        this.context = context != null ? context : new HashMap<>();
    }

    // Getters
    public String getCode() { return code; }
    public Map<String, Object> getContext() { return context; }

    // 添加上下文信息
    public JwpException withContext(String key, Object value) {
        this.context.put(key, value);
        return this;
    }
}